package com.jymj.service.impl;

import com.jymj.dao.ZjdSqDao;
import com.jymj.entity.CjEntity;
import com.jymj.entity.SysUserEntity;
import com.jymj.entity.model.CommonEnumEnty;
import com.jymj.entity.zjd.ZjdCountEntity;
import com.jymj.entity.zjd.ZjdSqEntity;
import com.jymj.service.ZjdSqService;
import com.jymj.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by dl on 2019/10/16.
 */
@Service
public class ZjdSqServiceImpl implements ZjdSqService {
    @Autowired
    private ZjdSqDao zjdSqDao;

    @Override
    public List<ZjdSqEntity> queryList(Map<String, Object> params) {
        /*SysUserEntity sysUserEntity = ShiroUtils.getUserEntity();
        params.put("sysUser",sysUserEntity);*/
        return zjdSqDao.queryList(params);
    }

    @Override
    public int queryTotal(Map<String, Object> params) {
       /*SysUserEntity sysUserEntity = ShiroUtils.getUserEntity();
        params.put("sysUser",sysUserEntity);*/
        return zjdSqDao.queryTotal(params);
    }

    @Override
    public ZjdSqEntity queryObjectByylId(Integer objectid) {
        return zjdSqDao.queryObjectByylId(objectid);
    }

    @Override
    public List<ZjdSqEntity> queryListById(Integer[] ids) {
        return zjdSqDao.queryListById(ids);
    }

    @Override
    public void deleteBatch(Integer[] ids) {
        zjdSqDao.deleteBatch(ids);
    }

    @Override
    public ZjdSqEntity queryObject(Integer id) {
        return zjdSqDao.queryObject(id);
    }

    @Override
    public boolean queryAllFile(Integer status, List<Integer> zjdSqFileIds) {
        List<CommonEnumEnty> commonEnumEnties = zjdSqDao.queryAllFile(status,zjdSqFileIds);
        for (CommonEnumEnty  commonEnum:commonEnumEnties) {
            if(commonEnum.getKey1()==null || commonEnum.getStatus1()==null){
                return false;
            }
        }
        return true;
    }

    @Override
    public int update(ZjdSqEntity zjdSqEntity) {
        return zjdSqDao.update(zjdSqEntity);
    }

    @Override
    public void updateYl(Integer ylId, Integer sptype) {
        zjdSqDao.updateYl(ylId,sptype);
    }

    @Override
    public boolean queryCount(Integer sptype, Integer id) {
        Integer i = zjdSqDao.queryCount(sptype,id);
        if (i < 1){
            return false;
        }
        return true;
    }

    @Override
    public CjEntity queryXzq(String geom) {
        return zjdSqDao.queryXzq(geom);
    }

    @Override
    public void save(ZjdSqEntity zjdSqEntity) {
        zjdSqDao.save(zjdSqEntity);
    }

    @Override
    public List<ZjdSqEntity> queryTypeCount(String xzqmc, Integer type) {
        Map map  = new HashMap();
        SysUserEntity sysUserEntity = ShiroUtils.getUserEntity();
        map.put("sysUser",sysUserEntity);
        map.put("xzqmc",xzqmc);
        map.put("type",type);
        return zjdSqDao.queryTypeCount(map);
    }

    @Override
    public ZjdCountEntity queryAllCount(String point, String code) {
        return zjdSqDao.queryAllCount(point,code);
    }
}
